using DG.Tweening;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using UnityEngine;


namespace IQIGame.Onigao.GamePlay
{
    public class UILightDialog : UIEntityWindow
    {
        /// <summary>
        /// 静态配置
        /// </summary>
        private static UICreateConfig _createConfig = new()
        {
            prefabName = nameof(UILightDialog),
            layer = EUILayer.Bottom,
        };

        /// <summary>
        /// 创建UI的配置
        /// </summary>
        public override IUICreateConfig createConfig => _createConfig;

        #region Template Generate,don't modify
        protected partial class UIB_UILevelLightDialog
        {
            #region ObjectBinding Generate
            public GameObject msgItem { protected set; get; }
            public GameObject alertItem { protected set; get; }
            public GameObject battleMsgItem { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.GameObject>("msgItem", out var __tbv0);
                this.msgItem = __tbv0;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("alertItem", out var __tbv1);
                this.alertItem = __tbv1;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("battleMsgItem", out var __tbv2);
                this.battleMsgItem = __tbv2;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        /// <summary>
        /// 可以自定义修改的
        /// </summary>
        protected partial class UIB_UILevelLightDialog
        {
            public virtual void StartBinding(GameObject __go)
            {
                var binding = __go.GetComponent<ObjectBinding>();
                if (binding != null)
                {
                    this.InitBinding(binding);
                }
            }
        }
        protected UIB_UILevelLightDialog ui { get; set; }

        protected override void BeforeInit()
        {
            ui = new UIB_UILevelLightDialog();
            ui.StartBinding(gameObject);
        }


        protected UIItemPool<UINLightDialogItem> _dialogPool;
        private UIItemPool<UIAlertItem> _alertItemPool;
        protected UIItemPool<UINLightDialogItem> _battleDialogPool;

        protected override void OnInit()
        {
            this.ui.msgItem.SetActive(false);
            this.ui.alertItem.SetActive(false);
            this.ui.battleMsgItem.SetActive(false);

            _dialogPool = this.InitPool<UINLightDialogItem>(this.ui.msgItem);
            _alertItemPool = this.InitPool<UIAlertItem>(this.ui.alertItem);
            _battleDialogPool = this.InitPool<UINLightDialogItem>(this.ui.battleMsgItem);
        }

        protected override void OnShow(UIBaseData data)
        {

        }

        protected override void OnHide()
        {

        }

        public UINLightDialogItem CreateDialogItem()
        {
            return _dialogPool.GetOne();
        }

        public void PutPoolDialogItem(UINLightDialogItem item)
        {
            item.transform.DOKill();
            _dialogPool.HideOne(item);
        }

        public UINLightDialogItem CreateBattleDialogItem()
        {
            return _battleDialogPool.GetOne();
        }

        public void PutPoolBattleDialogItem(UINLightDialogItem item)
        {
            item.transform.DOKill();
            _battleDialogPool.HideOne(item);
        }

        public UIAlertItem CreateAlertItem()
        {
            return _alertItemPool.GetOne();
        }

        public void PutPoolAlertItem(UIAlertItem item)
        {
            item.transform.DOKill();
            _alertItemPool.HideOne(item);
        }

        protected override void OnDispose()
        {
        }
    }
}
